const Mock = require('mockjs');

const List = [];
const count = 4;

for (let i = 1; i <= count; i++) {
    List.push(Mock.mock({
        'classifyId': i,
        'classifySuperior': 0,
        'classifyPicture': '1',
        'classifyZnName': '@word',
        'classifyCnName': '@cword(2,4)',
        'classifySort': '@increment()',
        'createdTime': '@date("yyyy-MM-dd hh:mm:ss")',
        'children': [{
            'classifyId': '@increment()',
            'classifySuperior': i,
            'classifyPicture': '1',
            'classifyZnName': '@word',
            'classifyCnName': '@cword(2,4)',
            'classifySort': '@increment()',
            'createdTime': '@date("yyyy-MM-dd hh:mm:ss")'
        }, {
            'classifyId': '@increment()',
            'classifySuperior': i,
            'classifyPicture': '1',
            'classifyZnName': '@word',
            'classifyCnName': '@cword(2,4)',
            'classifySort': '@increment()',
            'createdTime': '@date("yyyy-MM-dd hh:mm:ss")'
        }]
    }));
}

module.exports = [
    {
        url: '/classify/classifySearchObject',
        type: 'post',
        response: config => {
            const { page = 1, limit = 9999 } = config.body;
            const pageList = List.filter((item, index) => index < limit * page && index >= limit * (page - 1));

            return {
                code: 200,
                data: pageList,
                count: List.length,
                success: true
            };
        }
    }
];

